package com.dx_society.controller;

import com.dx_society.dto.Result;
import com.dx_society.service.MessageService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@CrossOrigin
@RequestMapping("/msg")
public class MsgController {
    @Resource
    private MessageService messageService;
    /**
     * 发送消息
     * @param receiveUserId 接收消息的用户id
     * @param message 消息内容
     * @return 发送消息结果
     */
    @PostMapping(value = "/send")
    public Result sendMsg(@RequestParam(value ="receiveUserId")Long receiveUserId, @RequestParam(value ="message")String message) {
        return messageService.sendMessage(receiveUserId, message);
    }

    /**
     * 查询未读消息
     * @return 未读消息列表
     */
    @GetMapping(value = "/unread")
    public Result queryUnreadMsg() {
        return messageService.queryUnreadMessage();
    }
    /**
     * 查询近期消息
     * @return 最近的一些消息
     */
    @GetMapping(value = "/recent")
    public Result queryInbox() {
        return messageService.queryRecent();
    }

    /**
     * 查询收件箱
     * @return 全部收件箱消息
     */
    @GetMapping(value = "/inbox")
    public Result queryInboxAll() {
        return messageService.queryInbox();
    }

    /**
     * 查询发件箱
     * @return 发件箱
     */
    @GetMapping(value = "/outbox")
    public Result queryOutMsg() {
        return messageService.queryOutMsg();
    }

}
